﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Abp.Application.Services.Dto;
using MyCompanyName.AbpZeroTemplate.CategoryApp;
using MyCompanyName.AbpZeroTemplate.CategoryApp.Dto;
using MyCompanyName.AbpZeroTemplate.Web.Areas.Mpa.Models.Category;
using Abp.Web.Mvc.Authorization;
using MyCompanyName.AbpZeroTemplate.Authorization;

namespace MyCompanyName.AbpZeroTemplate.Web.Areas.Mpa.Controllers
{
    [AbpMvcAuthorize(AppPermissions.Pages_Category)]
    public class CategoryController : Controller
    {
        private ICategoryAppService _categoryAppService;
        public CategoryController(ICategoryAppService categoryAppService)
        {
            _categoryAppService = categoryAppService;
        }
        // GET: Mpa/Category
        public ActionResult Index()
        {
            return View();
        }

        [AbpMvcAuthorize(AppPermissions.Pages_Category_Create)]
        public ActionResult CreateModal()
        {
            return PartialView("_CreateModal");
        }

        [AbpMvcAuthorize(AppPermissions.Pages_Category_Edit)]
        public ActionResult EditModal(int id)
        {
            CategoryOutput category=_categoryAppService.GetCategoryForEdit(new EntityRequestInput(id));
            CategoryViewModel categoryViewModel=new CategoryViewModel()
            {
                Id = category.Id,
                Name = category.Name
            };
            return PartialView("_EditModal", categoryViewModel);
        }
    }
}